//
//  BSTopicVideoView.m
//  baisibudejie
//
//  Created by 陈博文 on 15/12/27.
//  Copyright © 2015年 陈博文. All rights reserved.
//

#import "BSTopicVideoView.h"
#import "BSTopic.h"
#import <UIImageView+WebCache.h>

#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>

#define ScreenW [UIScreen mainScreen].bounds.size.width

@interface BSTopicVideoView ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *playCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *playTimeLabel;


@end


@implementation BSTopicVideoView

-(void)awakeFromNib{
    [super awakeFromNib];
    
}

-(void)setTopic:(BSTopic *)topic{
    
    _topic = topic;
    
    //对图片进行过滤
    if ((topic.isBigPicture)) {
        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
    }else{
        self.imageView.contentMode = UIViewContentModeScaleToFill;
    }
    
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:topic.image0]];
    
    //设置图片的模式为等比例缩放
    
    if (topic.playcount >= 10000) {
        self.playCountLabel.text = [NSString stringWithFormat:@"%.1f万次播放", topic.playcount / 10000.0];
    } else {
        self.playCountLabel.text = [NSString stringWithFormat:@"%zd次播放", topic.playcount];
    }
    
    // 时间
    NSInteger minute = topic.voicetime / 60;
    NSInteger second = topic.voicetime % 60;
    // %02zd : 用2位字符的空间来显示数字, 多余的空间用0来填补
    self.playTimeLabel.text = [NSString stringWithFormat:@"%02zd:%02zd", minute, second];
}

@end
